package vip.fuxk.blog.front;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeBuilder;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.lang.tree.parser.DefaultNodeParser;
import cn.hutool.core.lang.tree.parser.NodeParser;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.SearchResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.solon.annotation.Db;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.ModelAndView;
import org.smartboot.http.server.impl.HttpRequestImpl;
import vip.fuxk.blog.common.FuckBeanSearcher;
import vip.fuxk.blog.common.R;
import vip.fuxk.blog.dao.AppxMapper;
import vip.fuxk.blog.dao.DataMapper;
import vip.fuxk.blog.data.DataMetaVo;
import vip.fuxk.blog.data.DataQueryFieldValue;
import vip.fuxk.blog.data.DataVo;
import vip.fuxk.blog.entity.User;
import vip.fuxk.blog.service.DataService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class DemoController {
    @Db
    AppxMapper appxMapper;



    @Inject
    FuckBeanSearcher fuckBeanSearcher;

    @Inject
    private DataService dataService;

    @Mapping("testMapper")
    public Object data(){
        return dataService.getDataByName("前台菜单");
    }


    @Mapping("/dbtest")
    public Object test(){
        return appxMapper.selectList(Wrappers.query());
    }

    @Mapping("/userList")
    public IPage<User> userList() {
        return fuckBeanSearcher.search(User.class);
    }

    @Mapping("/hello")
    public String hello(@Param(defaultValue = "world") String name
    , HttpRequestImpl request) {
        return String.format("He %s!", name);
    }
    
    @Mapping("/hello2")
    public ModelAndView hello2(@Param(defaultValue = "world") String name) {
        return new ModelAndView("hello2.ftl").put("name", name);
    }
}